<script src="/public/static/common/js/jquery.2.1.1.min.js"></script>{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('AppID')}</label>
            <div class="layui-input-4">
                <input type="text" name="appid" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('AppID')}" value="{$wchat_config.appid}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Appsecret')}</label>
            <div class="layui-input-4">
                <input type="text" name="appsecret" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('Appsecret')}" value="{$wchat_config.appsecret}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                AppID以及Appsecret来自于您申请开发接口时提供的账号和密码。
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">URL</label>
            <div class="layui-input-4">
                <input class="layui-input" id="url" readonly value="{$call_back_url}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">TOKEN</label>
            <div class="layui-input-4">
                <input type="text" name="token" placeholder="输入TOKEN" class="layui-input" value="{$wchat_config.token}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                请将以上URL及Token填到微信公众平台中，以完成绑定。
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}

<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;
        form.on('submit(submit)', function (data) {
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post("{:url('setWechatConfig')}",data.field,function (res) {
                layer.close(loading);
                if(res.code > 0){
                    layer.msg(res.msg,{icon: 1, time: 1000},function(){
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{icon: 2, time: 1000});
                }
            });
        });

    })
</script>
</body>
</html>